#pragma once
#include<iostream>
using namespace std;

namespace my_reverse_iterator {


	template<class iterator, class Ref, class Ptr>
	struct list_reverse_iterator
	{
		typedef list_reverse_iterator<iterator, Ref, Ptr> reverse_iterator;
		iterator _it;
		list_reverse_iterator(iterator p)
			:_it(p)
		{}
		Ref operator *()
		{
			iterator tmp = _it;
			tmp--;
			return *tmp;
		}

		Ptr operator ->()
		{
			iterator tmp = _it;
			tmp--;
			return &tmp._node->_data;
		}

		reverse_iterator& operator ++()
		{
			return _it--;
		}

		reverse_iterator operator ++(int)
		{
			iterator tmp = _it;
			_it--;
			return tmp;
		}

		reverse_iterator& operator --()
		{
			return _it++;
		}

		reverse_iterator operator --(int)
		{
			iterator tmp = _it;
			_it++;
			return tmp;
		}

		bool operator!=(const reverse_iterator& it)const
		{
			return it._it != _it;
		}

		bool operator==(const reverse_iterator& it)const
		{
			return it._it == _it;
		}
	};
}